<?
require "include/bittorrent.php";
dbconn();

if (get_user_class() != UC_SYSOP)
error("Permission denied.");

if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST")
{
$username = trim($_POST["username"]);
$delenable = $_POST["delenable"];

if (!$username || !$delenable)
  error("Please fill out the form correctly.");

$res = query("SELECT * FROM users WHERE username=" . sqlesc($username)   ) or sqlerr();
if (mysql_num_rows($res) != 1)
  error("Bad user name.");
$arr = mysql_fetch_assoc($res);

$id = $arr['id'];
$res = query("DELETE FROM users WHERE id=$id") or sqlerr();
if (mysql_affected_rows() != 1)
  error("Unable to delete the account.");
alert("Success", "The account <b>$username</b> was deleted.");
}
stdhead("Delete account");
?>
<h1>Delete account</h1>
<table border=1 cellspacing=0 cellpadding=5>
<form method=post action=delacctadmin.php>
<tr><td class=rowhead>User name</td><td><input size=40 name=username></td></tr>

<tr><td>Verify <input name=delenable type=checkbox></td><td><input type=submit class=btn value='Delete'></td></tr>
</form>
</table>
<?
stdfoot();
?>